package com.cxg.caiec.demo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.widget.Toast;

import com.cxg.fairy.activities.ProxyActivity;
import com.cxg.fairy.app.Fairy;
import com.cxg.fairy.delegates.FairyDelegate;
import com.cxg.fairy.ec.launcher.LauncherDelegate;
import com.cxg.fairy.ec.launcher.LauncherScrollDelegate;
import com.cxg.fairy.ec.main.EcBottomDelegate;
import com.cxg.fairy.ec.sign.ISignListener;
import com.cxg.fairy.ec.sign.SignInDelegate;
import com.cxg.fairy.ec.sign.SignUpDelegate;
import com.cxg.fairy.ui.launcher.ILauncherListener;
import com.cxg.fairy.ui.launcher.OnLauncherFinishTag;

public class ExampleActivity extends ProxyActivity implements ISignListener,ILauncherListener{

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        Fairy.getConfigurator().withActivity(this);
    }

    @Override
    public FairyDelegate setRootDelegate() {
      return new LauncherDelegate();
    }


    @Override
    public void onSignInSuccess() {
        Toast.makeText(this,"登录成功!",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onSignUpSuccess() {
        Toast.makeText(this,"注册成功!",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void OnLauncherFinish(OnLauncherFinishTag tag) {
        switch (tag) {
            case SIGNED:
                Toast.makeText(this,"启动结束，用户已登录",Toast.LENGTH_SHORT).show();
//                startWithPop(new ExampleDelegate());
                startWithPop(new EcBottomDelegate());

                break;
            case NOT_SIGNED:
                Toast.makeText(this,"启动结束，用户未登录",Toast.LENGTH_SHORT).show();
                startWithPop(new SignInDelegate());
                break;
            default:
                break;
        }
    }
}
